<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class personnel_list2 extends Page
{
       public $btnSearch = null;
       public $edtSearch = null;
       public $Image4 = null;
       public $imgNext = null;
       public $imgBack = null;
       public $JSDelete = null;
       public $JSEdit = null;
       public $hiddenEmp = null;
       public $imgAdd = null;
       public $JTSiteTheme1 = null;
       public $JTEmpList = null;
       public $Image1 = null;


       function edtSearchJSClick($sender, $params)
       {

       ?>
       document.getElementById('edSearch').value = '';

       <?php

       }

       function imgNextJSClick($sender, $params)
       {

       ?>
       //var answer = confirm("Proceed to next step?");
	     //if(answer)
       //{
		    window.location.href = "set_vendor_list.php";
		   //}
       <?php

       }
       function imgNextJSMouseOut($sender, $params)
       {

       ?>
       document.images['imgNext'].src = 'image/btn_next.png';
       <?php

       }

       function imgNextJSMouseOver($sender, $params)
       {

       ?>
       document.images['imgNext'].src = 'image/btn_next2.png';
       <?php

       }

       function imgBackJSClick($sender, $params)
       {

       ?>
       window.location.href = "set_standard_droplist.php";

       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       document.images['imgBack'].src = 'image/btn_back1.png';
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       document.images['imgBack'].src = 'image/btn_back21.png';
       <?php

       }

       function imgAddJSClick($sender, $params)
       {

       ?>
       var win_height = 560;
       var win_width = 650;
       var height = window.opener.outerHeight;
       var width = window.opener.outerWidth;
       var top = Math.round((height-win_height)/2);
       var left = Math.round((width-win_width)/2);
       window.open('set_personnel_create.php','personnel_create_window','location=no,height='+win_height+',width='+win_width+',top='+top+',left='+left);
       <?php

       }

       function btnNextJSClick($sender, $params)
       {

       ?>
       var answer = confirm("Proceed to next step?");
	     if(answer)
       {
		    window.location.href = "set_vehicle_list.php";
		   }
       <?php

       }

       function imgAddJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new.png"
       <?php

       }

       function imgAddJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new_blue.png"
       <?php

       }

       function personnel_list2Create($sender, $params)
       {
       //$this->imgAdd->setLink('personnel_create.php');


       }


       function JTEmpListShow($sender, $params)
       {
       $search = $this->edtSearch->Text;
       $query1 = "select * from employee_tbl where company_id='".$_SESSION['company_id']."'
       AND (job_title LIKE '%".$search."%'
       OR terminate LIKE '%".$search."%'
       OR veh_op LIKE '%".$search."%')order by terminate ASC,job_title ASC";
       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {

            $emp = $row['autoid'];
            $title = $row['job_title'];
            $terminated = $row['terminate'];
            $veh_op = $row['veh_op'];

            if($veh_op==1)
            {
            $tools = "<img onclick=js_deletePersonnel('".$emp."'); src='image/delete.png' title='delete' style='cursor:pointer'>";
            }

            if($veh_op==0)
            {
            $tools = "<img onclick=js_deletePersonnel('".$emp."'); src='image/delete.png' title='delete' style='cursor:pointer'>";
            }

            if($terminated==1)
            {
            $color = "Silver";
            }

            if($terminated==0)
            {
            $color = "Black";
            }

            //$photo = "<img src='".$row['photo']."' height='50px' width='50px' onclick=js_edit('".$emp."') style='cursor:pointer'></img>";
            $photo = "<div align='center'><img src='".$row['photo']."' height='50px' width='50px' onclick=js_edit('".$emp."') style='cursor:pointer' border='2' title='edit'></div>";

            $arr[] = array(
                        'Photo' => "<p style='color:".$color."'>".$photo."</p>",
                        'Emp ID' => "<p style='color:".$color."'>".$row['emp_id']."</p>",
                        'Name' => "<p style='color:".$color."'>".$row['lname'].','.$row['fname']."</p>",
                        'Job Title' => "<p style='color:".$color."'>".$row['job_title']."</p>",
                        'Contact Num' => "<p style='color:".$color."'>".$row['phone_num']."</p>",
                        'Department' => "<p style='color:".$color."'>".$row['department']."</p>",
                        'Tools' => $tools
                        );


          }

            $this->JTEmpList->setCellData($arr);



       }

}

global $application;

global $personnel_list2;

//Creates the form
$personnel_list2=new personnel_list2($application);

//Read from resource file
$personnel_list2->loadResource(__FILE__);

//Shows the form
$personnel_list2->show();

?>